package com.truesai.entities.customer;

import java.math.BigDecimal;
import java.sql.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import com.truesai.dto.Gender;
/**
 * 客户详细信息<br/>
 * 需求分析<br/>
 * <strong>唯一性:</strong>客户名称。
 * @author XuLian
 *
 */
@Entity
@NamedQueries(
{
        @NamedQuery(name = Customer.ALL, query = "Select c from Customer c"),
        @NamedQuery(name = Customer.BY_NAME, query = "Select c from Customer c where c.name = :name"),
        @NamedQuery(name = Customer.BY_ID, query = "Select c from Customer c where c.id = :id") })
@Table(name = "Customers")
public class Customer {
	public static final String ALL = "Customer.all";

    public static final String BY_NAME = "Customer.byName";

    public static final String BY_ID = "Customer.byId";
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    /**客户姓名*/
    @Column(nullable = false)
    private String name;
    
    /**客户性别*/
    @Column
    @Enumerated(EnumType.ORDINAL)
    private Gender gender;
    
    /**住址*/
    @Column
    private String address;
    
    /**生日*/
    @Column
    private Date birthDay;
    
    /**联系电话（手机）*/
    @Column
    private String cellphone;
    
    /**联系电话（座机）*/
    @Column
    private String telephone;
    
    /**总消费次数*/
    @Column
    private Integer spendTimes;
    
    /**总消费*/
    @Column(scale=2)
    private BigDecimal totalSpend;
    
    /**总消费利润*/
    @Column(scale=2)
    private BigDecimal factProfit;
    
    /**平均每次消费*/
    @Column(scale=2)
    private BigDecimal spendAvg;
    
    /**平均每次消费利润*/
    @Column(scale=2)
    private BigDecimal profitAvg;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	/**@see #name  */
	public String getName() {
		return name;
	}

	/**@see #name  */
	public void setName(String name) {
		this.name = name;
	}

	/**@see #gender  */
	public Gender getGender() {
		return gender;
	}

	/**@see #gender  */
	public void setGender(Gender gender) {
		this.gender = gender;
	}

	/**@see #address  */
	public String getAddress() {
		return address;
	}

	/**@see #address  */
	public void setAddress(String address) {
		this.address = address;
	}

	/**@see #birthDay  */
	public Date getBirthDay() {
		return birthDay;
	}

	/**@see #birthDay  */
	public void setBirthDay(Date birthDay) {
		this.birthDay = birthDay;
	}

	/**@see #cellphone  */
	public String getCellphone() {
		return cellphone;
	}

	/**@see #cellphone  */
	public void setCellphone(String cellphone) {
		this.cellphone = cellphone;
	}

	/**@see #telephone  */
	public String getTelephone() {
		return telephone;
	}

	/**@see #telephone  */
	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}

	/**@see #spendTimes  */
	public Integer getSpendTimes() {
		return spendTimes;
	}

	/**@see #spendTimes  */
	public void setSpendTimes(Integer spendTimes) {
		this.spendTimes = spendTimes;
	}

	/**@see #totalSpend  */
	public BigDecimal getTotalSpend() {
		return totalSpend;
	}

	/**@see #totalSpend  */
	public void setTotalSpend(BigDecimal totalSpend) {
		this.totalSpend = totalSpend;
	}

	/**@see #factProfit  */
	public BigDecimal getFactProfit() {
		return factProfit;
	}

	/**@see #factProfit  */
	public void setFactProfit(BigDecimal factProfit) {
		this.factProfit = factProfit;
	}

	/**@see #spendAvg  */
	public BigDecimal getSpendAvg() {
		return spendAvg;
	}

	/**@see #spendAvg  */
	public void setSpendAvg(BigDecimal spendAvg) {
		this.spendAvg = spendAvg;
	}
	/**@see #profitAvg  */
	public BigDecimal getProfitAvg() {
		return profitAvg;
	}

	/**@see #profitAvg  */
	public void setProfitAvg(BigDecimal profitAvg) {
		this.profitAvg = profitAvg;
	}
    @Override
    public String toString() {
    	return name;
    }
    
    public Customer() { }
    
    public Customer(String name, Gender gender, String address, Date birthDay, 
    		String cellphone, String telephone, Integer spendTimes, BigDecimal totalSpend, 
    		BigDecimal factProfit, BigDecimal spendAvg, BigDecimal profitAvg) {
    	this.name = name;
    	this.gender = gender;
    	this.address = address;
    	this.birthDay = birthDay;
    	this.cellphone = cellphone;
    	this.telephone = telephone;
    	this.spendTimes = spendTimes;
    	this.totalSpend = totalSpend;
    	this.factProfit = factProfit;
    	this.spendAvg = spendAvg;
    	this.profitAvg = profitAvg;
    }
}
